From c62fffdcdc3490cf5c671eb428f8ca0036b7722a Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 13 Jan 2006 16:27:45 +0100 Subject: [PATCH] Fix writable pagetables when a flush happens in a different domain, which is temporarily made to run on the wrong pagetables. Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 1b4afa2fa2..79da37d3ea 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3023,12 +3023,25 @@ void ptwr_flush(struct domain *d, const int which) * STEP 2. Validate any modified PTEs. */ - pl1e = map_domain_page(l1e_get_pfn(pte)); - modified = revalidate_l1(d, pl1e, d->arch.ptwr[which].page); - unmap_domain_page(pl1e); - perfc_incr_histo(wpt_updates, modified, PT_UPDATES); - ptwr_eip_stat_update(d->arch.ptwr[which].eip, d->domain_id, modified); - d->arch.ptwr[which].prev_nr_updates = modified; + if ( likely(d == current->domain) ) + { + pl1e = map_domain_page(l1e_get_pfn(pte)); + modified = revalidate_l1(d, pl1e, d->arch.ptwr[which].page); + unmap_domain_page(pl1e); + perfc_incr_histo(wpt_updates, modified, PT_UPDATES); + ptwr_eip_stat_update(d->arch.ptwr[which].eip, d->domain_id, modified); + d->arch.ptwr[which].prev_nr_updates = modified; + } + else + { + /* + * Must make a temporary global mapping, since we are running in the + * wrong address space, so no access to our own mapcache. + */ + pl1e = map_domain_page_global(l1e_get_pfn(pte)); + modified = revalidate_l1(d, pl1e, d->arch.ptwr[which].page); + unmap_domain_page_global(pl1e); + } /* * STEP 3. Reattach the L1 p.t. page into the current address space. -- 2.30.2